﻿namespace DateAccessQAWebpart.DataAccessQA
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    using Microsoft.SharePoint;

    public partial class DataAccessQAUserControl : UserControl
    {
        #region Fields

        protected ListBox departmentListControl;
        protected Label errorLabel;

        #endregion Fields

        #region Methods

        protected void Page_Load( object sender, EventArgs e )
        {
            try
            {
                if ( !base.IsPostBack )
                {
                    DepartmentInformationBL departmentInformationBL = new DepartmentInformationBL( );
                    List<DepartmentInformation> dataSource = new List<DepartmentInformation>( );
                    List<DepartmentInformation> list = new List<DepartmentInformation>( );
                    List<DepartmentFields> list2 = new List<DepartmentFields>( );
                    string url = SPContext.Current.Web.Url;
                    departmentInformationBL.LoadDepartments( url, false );
                    dataSource = departmentInformationBL.DepartmentList;
                    departmentInformationBL.LoadDepartments( url, true );
                    list = departmentInformationBL.FixedDepartmentList;
                    this.errorLabel.Text = this.errorLabel.Text + "Number of Dept Items" + list.Count.ToString( );
                    this.departmentListControl.DataSource = dataSource;
                    this.departmentListControl.DataTextField = "DepartmentName";
                    this.departmentListControl.DataValueField = "ListName";
                    this.departmentListControl.DataBind( );
                }
            }
            catch ( Exception ex )
            {
                this.errorLabel.Text = this.errorLabel.Text + ex.Message;
            }
        }

        #endregion Methods
    }
}